package com.joinlabs.action;

import java.io.IOException;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.alibaba.fastjson.JSON;
import com.joinlabs.entity.Wares;
import com.joinlabs.service.IProductService;

@Controller
@RequestMapping("/index")
@SessionAttributes(names="wares")
public class IndexAction {
	@Resource
	private IProductService waresService;
	
	//主页的搜索查询
	@RequestMapping("/sousuo")
	public void selectlike(String likeName, ModelMap map,HttpServletResponse response) throws IOException {
		response.setContentType("text/html;charset=utf-8");
		List<Wares> wareslist = waresService.selectsousuo(likeName);
		String json = null;
		
		
		json = JSON.toJSONString(wareslist);
		response.getWriter().write(json);
	}
}
